#pragma once
#include <queue>
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include "Console.h"
#include "Position.h"
using namespace Course;

class Game
{
private:
	deque<char> keyPressQueue;

public:
	Game(){}
	~Game(){}

	void drawGameGrid()
	{
		int x = 0;
		int y = 0;
		for(int i = 1; i < 24; i++)
		{
			Console::gotoxy(0, i);
			cout << "|" << endl;
			Console::gotoxy(60, i);
			cout << "|" << endl;
		}
		for(int j = 0; j < 61; j++)
		{
			Console::gotoxy(j, 0);
			cout << "-" << endl;
			Console::gotoxy(j, 23);
			cout << "-" << endl;
		}
	}

	void getKeyPresses(deque<char> &kPQueue1, deque<char>  &kPQueue2)
	{
		if(_kbhit())
		{
			char c = _getch();
			if( c == 'w' || c == 'a' || c == 's' || c == 'd')
				kPQueue1.push_back(c);
			else if(c == 'i' || c == 'j' || c == 'k' || c == 'l')
				kPQueue2.push_back(c);
		}
	}

	void drawPlayer(deque<Position> &posQueue, int prev_x_p1, int prev_y_p1, int prev_x_p2, int prev_y_p2)
	{
		if(posQueue.size() > 0)
		{
			Position pos = posQueue.front();
			posQueue.pop_front();
			int x = pos.pos[0];
			int y = pos.pos[1];

			if(pos.id == 1)
			{
				Console::gotoxy(prev_x_p1, prev_y_p1);
				cout << " ";
				Console::gotoxy(x,y);
				cout << "X";
			}
			else if(pos.id == 2)
			{
				Console::gotoxy(prev_x_p2, prev_y_p2);
				cout << " ";
				Console::gotoxy(x,y);
				cout << "O";
			}
		}
	}
			

};